package com.heima.user.controller.feign;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.dtos.AuthDto;
import com.heima.model.user.pojos.ApUser;
import com.heima.user.service.ApUserRealnameService;
import com.heima.user.service.ApUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: xrl
 * @Date: 2022/10/22  16:10
 * @Version 1.0
 * 用户认证
 */
@RestController
public class ApUserRealnameClient {

    @Autowired
    private ApUserRealnameService apUserRealnameService;

    @Autowired
    private ApUserService apUserService;

    /**
     * 查询列表
     */
    @PostMapping("/api/v1/auth/list")
    public ResponseResult getList(@RequestBody AuthDto dto) {
        return apUserRealnameService.getList(dto);
    }

    /**
     * 审核失败
     * 审核失败，需要给出失败原因
     */
    @PostMapping("/api/v1/auth/authFail")
    public ResponseResult authFail(@RequestBody AuthDto dto) {
        return apUserRealnameService.authFail(dto);
    }

    /**
     * 审核成功
     * 用户通过审核后需要开通  自媒体账号 （该账号的用户名和密码与app一致）
     */
    @PostMapping("/api/v1/auth/authPass")
    public ResponseResult authPass(@RequestBody AuthDto dto) {
        return apUserRealnameService.authPass(dto);
    }

    /**
     * 查询app 用户信息
     */
    @PostMapping("/api/v1/user")
    public ApUser getUser(@RequestParam(value = "id",defaultValue = "4") Integer id ) {
        return apUserService.getUser(id);
    }


}
